<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自定义组件</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
</head>
<body>
<center>
    <div id="app">
        <h1>自定义指令</h1>
        <input type="text" v-focus />
    </div>
</center>
</body>
<script type="text/javascript">

    // 定义全局的自定义指令
    Vue.directive("focus", {
        inserted: function (el, binding, vnode, ) {
            el.focus()
        },
        bind: function (el) {
            console.log("指令被绑定");
        }
    });

    // 实例化vue对象
    let vm = new Vue({
        el: "#app",
        data: {
            msg: "大锤"
        }
    });


</script>
</html>